package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * 艾琳娜的夜光
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(18)
public class AilinnaStrategy extends BaseGameStrategy {
    public static final String URL = "http://111.170.174.196:804/ht/gzs.php";

    /**
     * qu: 2
     * gb: 111111
     * sqm: diyao88
     * usr: m66666
     * pay: 123
     * num: 223
     * item: 0
     * type: 7
     * @param item
     * @return
     */
    @GongnengMethod(1801)
    public String pay(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("type", "7");
        params.add("sqm", "diyao88");


        params.add("qu", item.qufu);
        params.add("pay", item.number);
        params.add("usr", item.uid);
        return RestTemplateUtil.sendPostForm(URL,params);
    }

    /**
     * qu: 2
     * gb: 111111
     * sqm: diyao88
     * usr: m66666
     * pay: 123
     * num: 231
     * item: 1
     * type: 8
     * @param item
     * @return
     */
    @GongnengMethod(1802)
    public String mail(SendItem item) {

        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("type", "8");
        params.add("sqm", "diyao88");

        params.add("qu", item.qufu);
        params.add("item", item.itemId);
        params.add("num", item.number);
        params.add("usr", item.uid);
        return RestTemplateUtil.sendPostForm(URL,params);
    }



    @GongnengMethod(9)
    public String clear(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }

    public static void main(String[] args) {
        SendItem item = new SendItem();
        item.qufu = "2";
        item.number = "12345";
        item.uid = "m66666";

//        new AAilinnaStrategy().pay(item);
        item.itemId = "1";
        System.out.println(new AilinnaStrategy().mail(item));
    }
}

